import { _decorator, Component, instantiate, Node, Prefab, sp } from 'cc';
import { BulletController } from './BulletController';
import { BundleManager, Bundles } from '../AshFramework/Managers/BundleManager';
import { GameManager } from './GameManager';
import { BulletHit } from './BulletHit';
import { Explosion_Bullet } from './Explosion_Bullet';

const { ccclass, property } = _decorator;


@ccclass('BulletController_LDP')
export class BulletController_LDP extends BulletController {

    removeSelf() {
        this.IsRemove = true;
        const worldPos = this.node.getWorldPosition().clone();
        const angle = this.node.angle;
        BundleManager.LoadPrefab(Bundles.Prefabs, "爆炸效果_子弹").then((prefab: Prefab) => {
            const hit = instantiate(prefab);
            hit.parent = GameManager.Instance.Canvas;
            hit.getComponent(Explosion_Bullet).show(worldPos, angle, this.Harm, this.ArmorPenetration);
        })
        this.scheduleOnce(() => { this.node.destroy(); })
    }
}


